<template>
  <div class="binding-page privacy-page">
    <div class="setting-page-right-title">
      <div class="setting-right-name">
        <div class="setting-top-name">屏蔽公司</div>
        <div class="setting-bottom-line"></div>
      </div>
      <div class="setting-title-right" @click="addShieldCompany">
        <i class="el-icon-circle-plus"></i>
        添加屏蔽公司
      </div>
    </div>
    <div class="privacy-content">
      <div class="privacy-content-title">
        您已经屏蔽
        <span>{{shieldCompanyList.length}}</span>个公司
      </div>
      <div class="privacy-company">
        <div class="privacy-company-list" v-for="(item,index) in shieldCompanyList" :key="index">
          {{item.companyName}}
          <el-button @click="closeShield(item.id)">取消屏蔽</el-button>
        </div>
      </div>
    </div>
    <el-dialog title="添加屏蔽公司" :visible.sync="dialogVisible" width="30%">
      <span class="privacy-dialog-text">屏蔽后，您的简历将不会投递到该公司</span>

      <el-input placeholder="输入想屏蔽的公司,仅支持公司全称" class="privacy-dialog-input" v-model="companyName">
        <el-button @click="shieldCompany()" slot="append" icon="el-icon-plus"></el-button>
      </el-input>
      <!-- <el-button @click="shieldCompany()">屏蔽所选公司</el-button> -->
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      companyName: '',
      companyList: [],
      shieldCompanyList: [],
      dialogVisible: false,
      search: ''
    }
  },
  methods: {
    getData() {
      //查询已经被屏蔽的公司
      _g.apiPost('/talent/initShieldCompany.do', {}).then(res => {
        this.shieldCompanyList = res.data
      })
    },
    //添加屏蔽公司的弹出框
    addShieldCompany() {
      this.dialogVisible = true
    },
    shieldCompany() {
      //屏蔽某个公司
      _g.apiPost('/talent/addShieldCompany.do', {
        companyName: this.companyName
      }).then(res => {
        _g.toMessage(res)
        if (res.status == 0) {
          this.dialogVisible = false
          this.getData()
        }
      })
    },
    searchCompany() {
      //搜索想要屏蔽的公司
      //console.log('搜索公司')
      _g.apiPost('/talent/getAllCompany.do', this.params).then(res => {
        this.companyList = res.data.list
        console.log(this.companyList)
      })
    },
    closeShield(id) {
      //取消屏蔽按钮

      _g.apiPost('/talent/delShieldCompany.do', { id: id }).then(res => {
        _g.toMessage({
          status: res.status,
          msg: res.status == 0 ? '取消成功' : '取消失败'
        })
        this.getData()
      })
    }
  },
  mounted() {
    this.getData()
  },
  components: {}
}
</script>

<style lang="scss" scoped>
</style>
